<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/3/3
  Time: 16:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <!--框架必需start-->
    <script type="text/javascript" src="static/qui/libs/js/jquery.js"></script>
    <script type="text/javascript" src="static/qui/libs/js/language/cn.js"></script>
    <script type="text/javascript" src="static/qui/libs/js/framework.js"></script>
    <link href="static/qui/libs/css/import_basic.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" id="skin" prePath="static/qui/" />
    <link rel="stylesheet" type="text/css" id="customSkin" />
    <script type="text/javascript" src="static/qui/libs/js/popup/toast.js"></script>

    <script src="static/qui/libs/js/form/validationRule.js" type="text/javascript"></script>
    <script src="static/qui/libs/js/form/validation.js" type="text/javascript"></script>

    <!--表单异步提交start-->
    <script src="static/qui/libs/js/form/form.js" type="text/javascript"></script>


</head>
<body>
<form id="userFrom" action="/user/add" method="post"  showOnMouseOver="false">
    <div class="page_content">
        <table class="formStyle">
            <input type="hidden" name="id" value="" />
            <tr>
                <td width="110" class="ali03">用户名：</td>
                <td width="200">
                    <input type="text"  id="account" name="account" value="" class="validate[required,custom[noSpecialCaracters]]"/>
                </td>
                <td width="15">
                    <span class="star">*</span>
            </td>
    <td>
        <div class="validation_info">请输入英文或数字</div>
    </td>
    </tr>
    <tr class="password">
        <td class="ali03">密码：</td>
        <td><input type="password" checkStrength="true" name="password" value="" id="password" class="validate[required,length[6,30],passwordStrength] "/> </td>
        <td>
            <span class="star">*</span>
        </td>
        <td><div class="validation_info">请输入6-11位的数字</div></td>
    </tr>
    <tr class="password">
        <td class="ali03">密码确认：</td>
        <td><input  type="password" class="validate[required,confirm[password]] float_left" value=""/></td>
        <td>
            <span class="star">*</span>
        </td>
        <td><div class="validation_info"></div></td>
    </tr>
    <tr >
        <td class="ali03">姓名：</td>
        <td><input type="text"  name="user_name" value="" class="validate[required,custom[chinese],length[0,20]] float_left"/></td>
        <td>
            <span class="star">*</span>
        </td>
        <td><div class="validation_info">请输入中文，20字以内</div></td>
    </tr>
            <tr>

                <td class="ali03">用户类型：</td>
                <td>
                    <input type="radio" id="male-1" name="user_type" value="0" /><label for="male-1" class="hand">教师</label>
                    <input type="radio" id="female-1" name="user_type" value="1" /><label for="female-1" class="hand">管理员</label>
                </td>
                <td>
                </td>
                <td></td>
            </tr>
    </table>
    </div>
</form>
<script>
    function getQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r!=null) return decodeURI(r[2]);
        return "";
    }
    var flag=getQueryString("flag");
    var id=getQueryString("id");
    if(flag==="edit"){
        $(".password").remove();
        $("#userFrom").attr("action","/user/editUser");
        $("#account").attr("disabled",true);
        $.getJSON("/user/getUserById",{"id":id},
            function(result){
                $('#userFrom').ajaxWrite({data:result.data});
                $("#password").val("");
            },"json");
    }
    function submitHandler(){
        var valid = $('#userFrom').validationEngine({returnIsValid: true, showOnMouseOver:false});
        if(valid){
            $('#userFrom').ajaxSubmit({
                //表单提交成功后的回调
                success: function(data, statusText, xhr, $form){
                    if(data.success){
                        top.Toast('showSuccessToast', data.msg);
                        //刷新数据
                        top.frmright.refresh();
                        //关闭窗口
                        top.Dialog.close();
                    }
                    else{
                        top.Toast('showWarningToast', data.msg);
                    }
                }
            });
        }
        return false;
    }
</script>
</body>
</html>
